﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using DeviceFinder.DAL;
using DeviceFinder.Models;

namespace DeviceFinder.Controllers
{
    public class RequestTokenController : ApiController
    {
        // GET api/requesttoken
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/requesttoken/5
        public string Get(int id)
        {
            return "value";
        }

        // POST api/requesttoken
        public RequestToken Post([FromBody]RequestTokenModel value)
        {
            RequestToken requestToken = null;
            try
            {
                requestToken = OAuthManager.CreateRequestToken(value.Email, value.Password);
            }
            catch (Exception e)
            {
                requestToken = new RequestToken() {Status = REQUEST_TOKEN_STATUS.FAIL, Token = e.Message };
            }
            return requestToken;
        }

        // PUT api/requesttoken/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/requesttoken/5
        public void Delete(int id)
        {
        }
    }
}
